package com.admins.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.admins.controller.PicturesController;
import com.admins.dao.ImageDao;
import com.admins.entity.Image;
import com.admins.service.ImageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author mis_wu
 * @date 2022/1/2 15:01
 */
@Service
@Transactional
public class ImageServiceImpl implements ImageService {

    private static final Logger log = LoggerFactory.getLogger(ImageServiceImpl.class);

    @Resource
    private ImageDao imageDao;

    /**
     * 查询
     * @param page
     * @param size
     * @param imgName
     * @param imgDesc
     * @return
     */
    @Override
    public PageInfo<Image> getImagesListByPage(int page, int size, String imgName, String imgDesc) {
        PageHelper.startPage(page,size);
        List<Image> list = imageDao.getImagesListByPage(imgName, imgDesc);
        return new PageInfo<Image>(list);
    }

    /**
     * 上传
     * @param image
     * @return
     */
    @Override
    public int collectionImg(Image image) {
        return imageDao.collectionImg(image);
    }
}
